package com.gin.no_gay_alliance.fragment.notice;

import android.view.LayoutInflater;
import android.view.View;

import androidx.annotation.NonNull;

import com.gin.no_gay_alliance.activity.PriMsgReadActivity;
import com.gin.no_gay_alliance.adpter.base.BaseBindingRecyclerViewAdapter;
import com.gin.no_gay_alliance.databinding.ItemNoticeMessageBinding;
import com.gin.no_gay_alliance.utils.ViewUtils;
import com.gin.no_gay_alliance.viewmodel.notice.MessageNoticeModel;

/**
 * 提醒消息 - 私信
 *
 * @author : ginstone
 * @version : v1.0.0
 * @since : 2023/9/11 12:28
 **/
public class MessageNoticeFragment extends BaseNoticeTabFragment<ItemNoticeMessageBinding, MessageNoticeModel> {
    @Override
    protected ItemNoticeMessageBinding buildBinding(LayoutInflater inflater) {
        return ItemNoticeMessageBinding.inflate(inflater);
    }

    /**
     * 绑定数据
     */
    @Override
    protected void onBindViewHolder(BaseBindingRecyclerViewAdapter.ViewHolder<ItemNoticeMessageBinding> holder, @NonNull ItemNoticeMessageBinding b, int position, MessageNoticeModel item) {
        b.tvContent.setText(item.description);
        b.tvTimestamp.setText(item.datetime);
        ViewUtils.setGone(item.read, b.tvNoRead);
    }

    /**
     * 点击事件统一处理
     *
     * @param v 被点击的View
     */
    @Override
    public void onClick(View v) {
        super.onClick(v);
        MessageNoticeModel i = (MessageNoticeModel) v.getTag();
        PriMsgReadActivity.startActivity(requireActivity(), i.messageId, -1, i.fromSystem);
    }


}
